{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "83f5f371",
   "metadata": {},
   "source": [
    "# NumPy基础"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f57281f6",
   "metadata": {},
   "source": [
    "导入NumPy:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "618da7f1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "c74d39c4",
   "metadata": {},
   "source": [
    "## 创建NumPy数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2a6c6365",
   "metadata": {},
   "outputs": [],
   "source": [
    "##keep\n",
    "a = np.array([1, 2, 3, 4, 5, 6])\n",
    "a"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f3e738f3",
   "metadata": {},
   "source": [
    "## 数组的属性"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d84af6b7",
   "metadata": {},
   "source": [
    "访问形状(shape)属性："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aceda4fd",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "d25d28c8",
   "metadata": {},
   "source": [
    "访问数据类型dtype:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "16549ad3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "6b6f3304",
   "metadata": {},
   "source": [
    "访问size属性："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e87fbedc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "b1a22d09",
   "metadata": {},
   "source": [
    "访问维度ndim："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cfbd7257",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "b56a93a2",
   "metadata": {},
   "source": [
    "## reshape"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c2a1add4",
   "metadata": {},
   "source": [
    "将a数组转换成2行3列："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "412150c4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "85301432",
   "metadata": {},
   "source": [
    "访问a的形状："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9ad37858",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "17669b8f",
   "metadata": {},
   "source": [
    "## Python列表与NumPy数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7a99bbb5",
   "metadata": {},
   "outputs": [],
   "source": [
    "##keep\n",
    "lst = [[1, 2, 3], [4, 5, 6]]\n",
    "lst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "601371f5",
   "metadata": {},
   "outputs": [],
   "source": [
    "##keep\n",
    "arr = np.arange(1, 7).reshape((2, 3))\n",
    "arr"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fd2da5a6",
   "metadata": {},
   "source": [
    "## 创建特定数组"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "442d7391",
   "metadata": {},
   "source": [
    "创建全为0的数组："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "52f5629e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "0d3bc544",
   "metadata": {},
   "source": [
    "创建全为1的数组："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "510708bf",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "228e1505",
   "metadata": {},
   "source": [
    "创建任意值数组（只为分配空间）："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "579b55ea",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f4b8090e",
   "metadata": {},
   "source": [
    "## 创建单调数组"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b8e44e79",
   "metadata": {},
   "source": [
    "创建元素从0到5的数组："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2c7f388c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "dd0f4604",
   "metadata": {},
   "source": [
    "创建从3到5的数组："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "90d2313b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "3953c69a",
   "metadata": {},
   "source": [
    "创建数组[1, 3, 5]："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3df3699d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "61b71084",
   "metadata": {},
   "source": [
    "用linspace创建如下形式的数组：\n",
    "```\n",
    "[0. , 0.1, 0.2, 0.3, 0.4, 0.5]\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0b37e276",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "89475212",
   "metadata": {},
   "source": [
    "用linspace创建如下形式的数组(10等分区间[0,1]的数组)：\n",
    "```\n",
    "[0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ]\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "da1d18c2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "84f0553a",
   "metadata": {},
   "source": [
    "## 生成随机数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "97746e71",
   "metadata": {},
   "source": [
    "生成 3 个 0 到 10 之间的随机数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "439de57b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "b26d9ade",
   "metadata": {},
   "source": [
    "Python自带random库的randint生成随机数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "88a82dab",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "27ecbf03",
   "metadata": {},
   "source": [
    "生成0到1之间（不包括1）满足均匀分布的随机数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "23dc2f2b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "14439788",
   "metadata": {},
   "source": [
    "生成3个满足标准正态分布的随机数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0d731d5a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
